#include "CMonsterConfigMgr.h"
#include <iostream>
#include <fstream>
#include "../maindef.h"
#include "../mainctrl.h"
#include "../skill/CSkill.h"

int CMonsterConfigMgr::LoadConfig(const char* sConfigFile)
{
    int iRet = 0;

    if (sConfigFile == NULL)
    {
        CT_ERROR(("sConfigFile is null"));
        return RET_SYSTEM_FAIL;
    }

    pb_cfg_monster stMonsterCfg;
    std::fstream stFileInput(sConfigFile, std::ios::in | std::ios::binary);
    if (!stMonsterCfg.ParseFromIstream(&stFileInput))
    {
        CT_ERROR(("Failed to Parse stMonsterCfg!"));
        return RET_SYSTEM_FAIL;
    }

    //注意加载顺序不能乱
    //加载击杀奖励配置
    for (int i = 0; i < stMonsterCfg.monster_kill_bonus_rows_size(); ++i)
    {
        const pb_cfg_monster_pb_cfg_monster_kill_bonus_unit & stMonsterKillBonusCfgUnit 
            = stMonsterCfg.monster_kill_bonus_rows(i);
    
        CMonsterKillBonusConfigData stConfigData;
        stConfigData._usMonsterGroupLevel = (unsigned short)(stMonsterKillBonusCfgUnit.monster_group_level() & 0x7FFF);
        stConfigData._uiExp = (unsigned int)(stMonsterKillBonusCfgUnit.exp_bonus() & 0x7FFFFFFF);
        stConfigData._uiSilver = (unsigned int)(stMonsterKillBonusCfgUnit.silver_bonus() & 0x7FFFFFFF);
        stConfigData._uiLilian = (unsigned int)(stMonsterKillBonusCfgUnit.lilian_bonus() & 0x7FFFFFFF);

        iRet = _stMonsterKillBonusConfig.AddConfig(stConfigData);
        CT_RETURN(iRet);
    }

    //加载怪物属性表
    for (int i = 0; i < stMonsterCfg.monster_attr_rows_size(); ++i)
    {
        const pb_cfg_monster_pb_cfg_monster_attr_unit & stMonsterAttrCfgUnit 
            = stMonsterCfg.monster_attr_rows(i);

        CMonsterAttrConfigData stConfigData;
        stConfigData._usLevel = (unsigned short)(stMonsterAttrCfgUnit.level() & 0x7FFF);

        std::string sTmp = stMonsterAttrCfgUnit.hp();
        const std::string sDel = ",";
        std::vector<std::string> vContents;

        CTStringUtils::Split(sTmp, sDel, vContents);

        if ((int)vContents.size() > stConfigData._auiHP.GetCount())
        {
            CT_ERROR((""));
            return RET_SYS_ERROR;
        }

        for (int i = 0; i < (int)vContents.size(); ++i)
        {
            stConfigData._auiHP[i] = (unsigned int)atoi(vContents[i].c_str());
        }

        stConfigData._uiPhyAtk = (unsigned int)(stMonsterAttrCfgUnit.phy_atk() & 0x7FFFFFFF);
        stConfigData._uiPhyDef = (unsigned int)(stMonsterAttrCfgUnit.phy_def() & 0x7FFFFFFF);
        stConfigData._uiMagAtk = (unsigned int)(stMonsterAttrCfgUnit.mag_atk() & 0x7FFFFFFF);
        stConfigData._uiMagDef = (unsigned int)(stMonsterAttrCfgUnit.mag_def() & 0x7FFFFFFF);
        
        stConfigData._uiEarthAtk = (unsigned int)(stMonsterAttrCfgUnit.earth_atk() & 0x7FFFFFFF);
        stConfigData._uiWaterAtk = (unsigned int)(stMonsterAttrCfgUnit.water_atk() & 0x7FFFFFFF);
        stConfigData._uiFireAtk = (unsigned int)(stMonsterAttrCfgUnit.fire_atk() & 0x7FFFFFFF);
        stConfigData._uiWindAtk = (unsigned int)(stMonsterAttrCfgUnit.wind_atk() & 0x7FFFFFFF);

        stConfigData._uiHitLevel = (unsigned int)(stMonsterAttrCfgUnit.hit_level() & 0x7FFFFFFF);
        stConfigData._uiDodgeLevel = (unsigned int)(stMonsterAttrCfgUnit.dodge_level() & 0x7FFFFFFF);
        stConfigData._uiDoubleLevel = (unsigned int)(stMonsterAttrCfgUnit.double_level() & 0x7FFFFFFF);
        stConfigData._uiAntiDoubleLevel = (unsigned int)(stMonsterAttrCfgUnit.anti_double_level() & 0x7FFFFFFF);
        stConfigData._uiCritLevel = (unsigned int)(stMonsterAttrCfgUnit.crit_level() & 0x7FFFFFFF);
        stConfigData._uiBlockLevel = (unsigned int)(stMonsterAttrCfgUnit.block_level() & 0x7FFFFFFF);
        stConfigData._uiAntiBlockLevel = (unsigned int)(stMonsterAttrCfgUnit.anti_block_level() & 0x7FFFFFFF);

        stConfigData._uiTurnOrderValue = (unsigned int)(stMonsterAttrCfgUnit.turn_order_value() & 0x7FFFFFFF);
        stConfigData._uiInitAnger = (unsigned int)(stMonsterAttrCfgUnit.init_anger() & 0x7FFFFFFF);
        stConfigData._uiAngerRecoverRate = (unsigned int)(stMonsterAttrCfgUnit.anger_recover_rate() & 0x7FFFFFFF);
        stConfigData._uiInitCourage = (unsigned int)(stMonsterAttrCfgUnit.init_courage() & 0x7FFFFFFF);
        stConfigData._uiCourageRecoverRate = (unsigned int)(stMonsterAttrCfgUnit.courage_recover_rate() & 0x7FFFFFFF);
        stConfigData._uiImmuneInjuryRate = (unsigned int)(stMonsterAttrCfgUnit.immune_injury_rate() & 0x7FFFFFFF);
        stConfigData._uiReactInjuryRate = (unsigned int)(stMonsterAttrCfgUnit.react_injury_rate() & 0x7FFFFFFF);
        stConfigData._uiPenetrateRate = (unsigned int)(stMonsterAttrCfgUnit.penetrate_rate() & 0x7FFFFFFF);
        stConfigData._uiTreatmentRate = (unsigned int)(stMonsterAttrCfgUnit.treatment_rate() & 0x7FFFFFFF);
        stConfigData._uiFightBackRate = (unsigned int)(stMonsterAttrCfgUnit.fight_back_rate() & 0x7FFFFFFF);

        iRet = _stMonsterAttrConfig.AddConfig(stConfigData);
        CT_RETURN(iRet);
    }

    //加载类型表
    for (int i = 0; i < stMonsterCfg.monster_type_rows_size(); ++i)
    {
        const pb_cfg_monster_pb_cfg_monster_type_unit & stMonsterTypeCfgUnit 
            = stMonsterCfg.monster_type_rows(i);
    
        CMonsterTypeConfigData stConfigData;
        stConfigData._usMonsterType = (unsigned short)(stMonsterTypeCfgUnit.monster_type() & 0x7FFF);

        stConfigData._uiHpAdjust = (unsigned int)(stMonsterTypeCfgUnit.hp_adjust() & 0x7FFFFFFF);
        stConfigData._iHPBasePos = stMonsterTypeCfgUnit.hp_base_pos();
        stConfigData._uiPhyAtkAdjust = (unsigned int)(stMonsterTypeCfgUnit.phy_atk_adjust() & 0x7FFFFFFF);
        stConfigData._uiPhyDefAdjust = (unsigned int)(stMonsterTypeCfgUnit.phy_def_adjust() & 0x7FFFFFFF);
        stConfigData._uiMagAtkAdjust = (unsigned int)(stMonsterTypeCfgUnit.mag_atk_adjust() & 0x7FFFFFFF);
        stConfigData._uiMagDefAdjust = (unsigned int)(stMonsterTypeCfgUnit.mag_def_adjust() & 0x7FFFFFFF);

        stConfigData._uiEarthAtkAdjust = (unsigned int)(stMonsterTypeCfgUnit.earth_atk_adjust() & 0x7FFFFFFF);
        stConfigData._uiWarterAtkAdjust = (unsigned int)(stMonsterTypeCfgUnit.water_atk_adjust() & 0x7FFFFFFF);
        stConfigData._uiFireAtkAdjust = (unsigned int)(stMonsterTypeCfgUnit.fire_atk_adjust() & 0x7FFFFFFF);
        stConfigData._uiWindAtkAdjust = (unsigned int)(stMonsterTypeCfgUnit.wind_atk_adjust() & 0x7FFFFFFF);

        stConfigData._uiHitLevelAdjust = (unsigned int)(stMonsterTypeCfgUnit.hit_level_adjust() & 0x7FFFFFFF);
        stConfigData._uiDodgeLevelAdjust = (unsigned int)(stMonsterTypeCfgUnit.dodge_level_adjust() & 0x7FFFFFFF);
        stConfigData._uiDoubleLevelAdjust = (unsigned int)(stMonsterTypeCfgUnit.double_level_adjust() & 0x7FFFFFFF);
        stConfigData._uiAntiDoubleLevelAdjust = (unsigned int)(stMonsterTypeCfgUnit.anti_double_level_rate_adjust() & 0x7FFFFFFF);
        stConfigData._uiCritLevelAdjust = (unsigned int)(stMonsterTypeCfgUnit.crit_level_adjust() & 0x7FFFFFFF);
        stConfigData._uiBlockLevelAdjust = (unsigned int)(stMonsterTypeCfgUnit.block_level_adjust() & 0x7FFFFFFF);
        stConfigData._uiAntiBlockLevelAdjust = (unsigned int)(stMonsterTypeCfgUnit.anti_block_level_adjust() & 0x7FFFFFFF);

        stConfigData._uiTurnOrderValueAdjust = (unsigned int)(stMonsterTypeCfgUnit.turn_order_value_adjust() & 0x7FFFFFFF);
        stConfigData._uiInitAngerAdjust = (unsigned int)(stMonsterTypeCfgUnit.init_anger_adjust() & 0x7FFFFFFF);
        stConfigData._uiAngerRecoverRateAdjust = (unsigned int)(stMonsterTypeCfgUnit.anger_recover_rate_adjust() & 0x7FFFFFFF);
        stConfigData._uiInitCourageAdjust = (unsigned int)(stMonsterTypeCfgUnit.init_courage_adjust() & 0x7FFFFFFF);
        stConfigData._uiCourageRecoverRateAdjust = (unsigned int)(stMonsterTypeCfgUnit.courage_recover_rate_adjust() & 0x7FFFFFFF);
        stConfigData._uiFightBackRateAdjust = (unsigned int)(stMonsterTypeCfgUnit.fight_back_rate_adjust() & 0x7FFFFFFF);
        stConfigData._uiImmuneInjuryRateAdjust = (unsigned int)(stMonsterTypeCfgUnit.immune_injury_rate_adjust() & 0x7FFFFFFF);
        stConfigData._uiReactInjuryRateAdjust = (unsigned int)(stMonsterTypeCfgUnit.react_injury_rate_adjust() & 0x7FFFFFFF);
        stConfigData._uiPenetrateRateAdjust = (unsigned int)(stMonsterTypeCfgUnit.penetrate_rate_adjust() & 0x7FFFFFFF);
        stConfigData._uiTreatmentRateAdjust = (unsigned int)(stMonsterTypeCfgUnit.treatment_rate_adjust() & 0x7FFFFFFF);

        iRet = _stMonsterTypeConfig.AddConfig(stConfigData);
        CT_RETURN(iRet);
    }

    //加载怪物列表
    for (int i = 0; i < stMonsterCfg.monster_list_rows_size(); ++i)
    {
        const pb_cfg_monster_pb_cfg_monster_list_unit & stMonsterListCfgUnit 
            = stMonsterCfg.monster_list_rows(i);

        CMonsterConfigData stConfigData;
        stConfigData._ucCareer = (unsigned char)(stMonsterListCfgUnit.career() & 0x7F);
        stConfigData._uiMonsterID = (unsigned int)(stMonsterListCfgUnit.monster_id() & 0x7FFFFFFF);
        stConfigData._usMonsterType = (unsigned short)(stMonsterListCfgUnit.type_id() & 0x7FFF);
        stConfigData._usDefaultLevel = (unsigned short)(stMonsterListCfgUnit.default_level() & 0x7FFF);
        
        stConfigData._uiNormalSkillID = (unsigned int)(stMonsterListCfgUnit.normal_skill_id() & 0x7FFFFFFF);
        stConfigData._uiAcademySkillID = (unsigned int)(stMonsterListCfgUnit.academy_skill_id() & 0x7FFFFFFF);
        stConfigData._uiMagicSkillID = (unsigned int)(stMonsterListCfgUnit.magic_skill_id() & 0x7FFFFFFF);

        stConfigData._iStatusGroupID = stMonsterListCfgUnit.status_group();

        iRet = CMainCtrl::m_pstMain->m_stRoleMgr.CheckValidCareer(
            stConfigData._ucCareer);
        CT_RETURN(iRet);

        iRet = CMainCtrl::m_pstMain->m_stSkillMgr.IsValidSkill(
            stConfigData._uiNormalSkillID, CSkill::SKILL_TYPE_NORMAL);
        CT_RETURN(iRet);

        iRet = CMainCtrl::m_pstMain->m_stSkillMgr.IsValidSkill(
            stConfigData._uiAcademySkillID, CSkill::SKILL_TYPE_ACADEMIC);
        CT_RETURN(iRet);

        iRet = CMainCtrl::m_pstMain->m_stSkillMgr.IsValidSkill(
            stConfigData._uiMagicSkillID, CSkill::SKILL_TYPE_MAGIC);
        CT_RETURN(iRet);

        iRet = CMainCtrl::m_pstMain->m_stStatusMgr.IsValidStatusGroup(
            stConfigData._iStatusGroupID);
        CT_RETURN(iRet);

        iRet = GetMonsterAttr(stConfigData._uiMonsterID,
                stConfigData._usDefaultLevel, stConfigData._usMonsterType,
                stConfigData._stMonsterDefaultAttr);

        if (RET_OK != iRet)
        {
            CT_ERROR(("%d, %d, %d, ret = %d", 
                      stConfigData._uiMonsterID, stConfigData._usDefaultLevel,
                      stConfigData._usMonsterType, iRet));
            return iRet;
        }

        iRet = _stMonsterConfig.AddConfig(stConfigData);
        CT_RETURN(iRet);
    }

    //怪物队伍表
    for (int i = 0; i < stMonsterCfg.monster_group_rows_size(); ++i)
    {
        const pb_cfg_monster_pb_cfg_monster_group_unit & stMonsterGroupCfgUnit 
            = stMonsterCfg.monster_group_rows(i);

        CMonsterGroupConfigData stConfigData;
        stConfigData._uiMonsterGroupID = (unsigned int)(stMonsterGroupCfgUnit.monster_group_id() & 0x7FFFFFFF);
        stConfigData._usDefaultLevel = (unsigned short)(stMonsterGroupCfgUnit.default_level() & 0x7FFF);
        stConfigData._bHasFirstKillBonus = stMonsterGroupCfgUnit.has_first_kill_bonus() != 0;
        stConfigData._ucIsBoss = (unsigned char)(stMonsterGroupCfgUnit.is_boss() & 0x7F);

        CMonsterGroupMember stMonsterMember1;
        stMonsterMember1._uiMonsterID = (unsigned int)(stMonsterGroupCfgUnit.monster1_id() & 0x7FFFFFFF);
        stMonsterMember1._usPos = (unsigned short)(stMonsterGroupCfgUnit.monster1_pos() & 0x7FFF);
        stMonsterMember1._ucTurnOrder = (unsigned char)(stMonsterGroupCfgUnit.monster1_turn_order() & 0x7F);
        iRet = _stMonsterConfig.GetConfig(stMonsterMember1._uiMonsterID, stMonsterMember1._stMonster);
        CT_RETURN(iRet);
        stMonsterMember1._stMonster._usDefaultLevel = stConfigData._usDefaultLevel;
        stConfigData._astMonsters.AddOneItem(stMonsterMember1);

        CMonsterGroupMember stMonsterMember2;
        stMonsterMember2._uiMonsterID = (unsigned int)(stMonsterGroupCfgUnit.monster2_id() & 0x7FFFFFFF);
        if (stMonsterMember2._uiMonsterID > 0)
        {
       		stMonsterMember2._usPos = (unsigned short)(stMonsterGroupCfgUnit.monster2_pos() & 0x7FFF);
       		stMonsterMember2._ucTurnOrder = (unsigned char)(stMonsterGroupCfgUnit.monster2_turn_order() & 0x7F);
       		iRet = _stMonsterConfig.GetConfig(stMonsterMember2._uiMonsterID, stMonsterMember2._stMonster);
       		CT_RETURN(iRet);
       		stMonsterMember2._stMonster._usDefaultLevel = stConfigData._usDefaultLevel;
       		stConfigData._astMonsters.AddOneItem(stMonsterMember2);
        }

        CMonsterGroupMember stMonsterMember3;
        stMonsterMember3._uiMonsterID = (unsigned int)(stMonsterGroupCfgUnit.monster3_id() & 0x7FFFFFFF);
        if (stMonsterMember3._uiMonsterID > 0)
        {
       		stMonsterMember3._usPos = (unsigned short)(stMonsterGroupCfgUnit.monster3_pos() & 0x7FFF);
       		stMonsterMember3._ucTurnOrder = (unsigned char)(stMonsterGroupCfgUnit.monster3_turn_order() & 0x7F);
       		iRet = _stMonsterConfig.GetConfig(stMonsterMember3._uiMonsterID, stMonsterMember3._stMonster);
       		CT_RETURN(iRet);
       		stMonsterMember3._stMonster._usDefaultLevel = stConfigData._usDefaultLevel;
       		stConfigData._astMonsters.AddOneItem(stMonsterMember3);
        }

        CMonsterGroupMember stMonsterMember4;
        stMonsterMember4._uiMonsterID = (unsigned int)(stMonsterGroupCfgUnit.monster4_id() & 0x7FFFFFFF);
        if (stMonsterMember4._uiMonsterID > 0)
        {
       		stMonsterMember4._usPos = (unsigned short)(stMonsterGroupCfgUnit.monster4_pos() & 0x7FFF);
       		stMonsterMember4._ucTurnOrder = (unsigned char)(stMonsterGroupCfgUnit.monster4_turn_order() & 0x7F);
       		iRet = _stMonsterConfig.GetConfig(stMonsterMember4._uiMonsterID, stMonsterMember4._stMonster);
       		CT_RETURN(iRet);
       		stMonsterMember4._stMonster._usDefaultLevel = stConfigData._usDefaultLevel;
       		stConfigData._astMonsters.AddOneItem(stMonsterMember4);
        }
    
        CMonsterGroupMember stMonsterMember5;
        stMonsterMember5._uiMonsterID = (unsigned int)(stMonsterGroupCfgUnit.monster5_id() & 0x7FFFFFFF);
        if (stMonsterMember5._uiMonsterID > 0)
        {
       		stMonsterMember5._usPos = (unsigned short)(stMonsterGroupCfgUnit.monster5_pos() & 0x7FFF);
       		stMonsterMember5._ucTurnOrder = (unsigned char)(stMonsterGroupCfgUnit.monster5_turn_order() & 0x7F);
       		iRet = _stMonsterConfig.GetConfig(stMonsterMember5._uiMonsterID, stMonsterMember5._stMonster);
       		CT_RETURN(iRet);
       		stMonsterMember5._stMonster._usDefaultLevel = stConfigData._usDefaultLevel;
       		stConfigData._astMonsters.AddOneItem(stMonsterMember5);
        }

        iRet = _stMonsterGroupConfig.AddConfig(stConfigData);
        CT_RETURN(iRet);
    }

    //首次击杀怪物奖励
    for (int i = 0; i < stMonsterCfg.monster_first_kill_bonus_rows_size(); ++i)
    {
        const pb_cfg_monster_pb_cfg_monster_first_kill_bonus_unit & stMonsterFirstKillCfgUnit 
                                    = stMonsterCfg.monster_first_kill_bonus_rows(i);

        CMonsterFirstKillBonusConfigData stConfigData;
        stConfigData._usMonsterGroupLevel = (unsigned short)(stMonsterFirstKillCfgUnit.monster_group_level() & 0x7FFF);
        stConfigData._uiHunli = (unsigned int)(stMonsterFirstKillCfgUnit.hunli() & 0x7FFFFFFF);

        iRet = _stMonsterFirstKillBonusConfig.AddConfig(stConfigData);
        CT_RETURN(iRet);
    }

    return 0;
}

int CMonsterConfigMgr::GetMonsterAttr(unsigned int uiMonsterID, unsigned short usLevel, unsigned short usMonsterType, CMonsterAttrConfigData& stAttrData)
{
    int iRet = 0;
    int iIndex = 0;
    
    iIndex = _stMonsterConfig.FindConfig(uiMonsterID);
    if (iIndex >= 0)
    {
        CMonsterConfigData& stMonsterData = _stMonsterConfig.GetConfig(iIndex);
        if (usLevel == stMonsterData._stMonsterDefaultAttr._usLevel)
        {
            stAttrData = stMonsterData._stMonsterDefaultAttr;
            return 0;
        }
    }

    CMonsterAttrConfigData stMonsterAttrData;
    iRet = _stMonsterAttrConfig.GetConfig(usLevel, stMonsterAttrData);
    CT_RETURN(iRet);

    CMonsterTypeConfigData stMonsterTypeData;
    iRet = _stMonsterTypeConfig.GetConfig(usMonsterType, stMonsterTypeData);
    if (iRet != RET_OK)
    {
        CT_ERROR(("monsterid %d, monster type %d", uiMonsterID, usMonsterType));
        return iRet;
    }

    stAttrData._uiHP = (unsigned int)((int64)stMonsterAttrData.GetHP(stMonsterTypeData._iHPBasePos) * stMonsterTypeData._uiHpAdjust / COMM_MOD);
    stAttrData._uiPhyAtk = (unsigned int)((int64)stMonsterAttrData._uiPhyAtk * stMonsterTypeData._uiPhyAtkAdjust / COMM_MOD);
    stAttrData._uiPhyDef = (unsigned int)((int64)stMonsterAttrData._uiPhyDef * stMonsterTypeData._uiPhyDefAdjust / COMM_MOD);
    stAttrData._uiMagAtk = (unsigned int)((int64)stMonsterAttrData._uiMagAtk * stMonsterTypeData._uiMagAtkAdjust / COMM_MOD);
    stAttrData._uiMagDef = (unsigned int)((int64)stMonsterAttrData._uiMagDef * stMonsterTypeData._uiMagDefAdjust / COMM_MOD);
    
    stAttrData._uiEarthAtk = (unsigned int)((int64)stMonsterAttrData._uiEarthAtk * stMonsterTypeData._uiEarthAtkAdjust / COMM_MOD);
    stAttrData._uiWaterAtk = (unsigned int)((int64)stMonsterAttrData._uiWaterAtk * stMonsterTypeData._uiWarterAtkAdjust / COMM_MOD);
    stAttrData._uiFireAtk = (unsigned int)((int64)stMonsterAttrData._uiFireAtk * stMonsterTypeData._uiFireAtkAdjust / COMM_MOD);
    stAttrData._uiWindAtk = (unsigned int)((int64)stMonsterAttrData._uiWindAtk * stMonsterTypeData._uiWindAtkAdjust / COMM_MOD);

    stAttrData._uiHitLevel = (unsigned int)((int64)stMonsterAttrData._uiHitLevel * stMonsterTypeData._uiHitLevelAdjust / COMM_MOD);
    stAttrData._uiDodgeLevel = (unsigned int)((int64)stMonsterAttrData._uiDodgeLevel * stMonsterTypeData._uiDodgeLevelAdjust / COMM_MOD);
    stAttrData._uiDoubleLevel = (unsigned int)((int64)stMonsterAttrData._uiDoubleLevel * stMonsterTypeData._uiDoubleLevelAdjust / COMM_MOD);
    stAttrData._uiAntiDoubleLevel = (unsigned int)((int64)stMonsterAttrData._uiAntiDoubleLevel * stMonsterTypeData._uiAntiDoubleLevelAdjust / COMM_MOD);
    stAttrData._uiCritLevel = (unsigned int)((int64)stMonsterAttrData._uiCritLevel * stMonsterTypeData._uiCritLevelAdjust / COMM_MOD);
    stAttrData._uiBlockLevel = (unsigned int)((int64)stMonsterAttrData._uiBlockLevel * stMonsterTypeData._uiBlockLevelAdjust / COMM_MOD);
    stAttrData._uiAntiBlockLevel = (unsigned int)((int64)stMonsterAttrData._uiAntiBlockLevel * stMonsterTypeData._uiAntiBlockLevelAdjust / COMM_MOD);
    
    stAttrData._uiTurnOrderValue = (unsigned int)((int64)stMonsterAttrData._uiTurnOrderValue * stMonsterTypeData._uiTurnOrderValueAdjust / COMM_MOD);
    stAttrData._uiInitAnger = (unsigned int)((int64)stMonsterAttrData._uiInitAnger * stMonsterTypeData._uiInitAngerAdjust / COMM_MOD);
    stAttrData._uiAngerRecoverRate = (unsigned int)((int64)stMonsterAttrData._uiAngerRecoverRate * stMonsterTypeData._uiAngerRecoverRateAdjust / COMM_MOD);
    stAttrData._uiInitCourage = (unsigned int)((int64)stMonsterAttrData._uiInitCourage * stMonsterTypeData._uiInitCourageAdjust / COMM_MOD);
    stAttrData._uiCourageRecoverRate = (unsigned int)((int64)stMonsterAttrData._uiCourageRecoverRate * stMonsterTypeData._uiCourageRecoverRateAdjust / COMM_MOD);
    stAttrData._uiFightBackRate = (unsigned int)((int64)stMonsterAttrData._uiFightBackRate * stMonsterTypeData._uiFightBackRateAdjust / COMM_MOD);
    stAttrData._uiImmuneInjuryRate = (unsigned int)((int64)stMonsterAttrData._uiImmuneInjuryRate * stMonsterTypeData._uiImmuneInjuryRateAdjust / COMM_MOD);
    stAttrData._uiReactInjuryRate = (unsigned int)((int64)stMonsterAttrData._uiReactInjuryRate * stMonsterTypeData._uiReactInjuryRateAdjust / COMM_MOD);
    stAttrData._uiPenetrateRate = (unsigned int)((int64)stMonsterAttrData._uiPenetrateRate * stMonsterTypeData._uiPenetrateRateAdjust / COMM_MOD);
    stAttrData._uiTreatmentRate = (unsigned int)((int64)stMonsterAttrData._uiTreatmentRate * stMonsterTypeData._uiTreatmentRateAdjust / COMM_MOD);

    return 0;
}

